
#include "source_line.h"

#include <stdio.h>
#include <string.h>
#include "exception.h"

SourceLine::SourceLine(char * line)
{
	int count = (int) strlen(line);
	int realCount = count;
	for(int i = 0; i < count; i++)
	{
/*		// If there is LF or CR inside...
		if(line[i] == '0x0A' || line[i] == '0x0D')
		{
			realCount = i + 1;
			break;
		}
*/
	}

	try
	{
		lineCharacters = new char[realCount + 1];
	}
	catch(...)
	{
		lineCharacters = NULL;
		throw exception("Can't alloc source line parameters.");
	}
    
	for(int i = 0; i < realCount; i++)
	{
		lineCharacters[i] = line[i];
	}

	lineCharacters[realCount] = '\0';
}


SourceLine::~SourceLine()
{
	if(lineCharacters != NULL)
	{
		delete[] lineCharacters;
		lineCharacters = NULL;
	}
}
